const express = require('express');
const router = express.Router();
const db = require('../db/db')

// 查询学校
router.post('/searchSch', (req, res) => {
  console.log(req.url);
  let content = req.body.content;
  console.log(content);
 if(content == []) {
   res.send([])
   
 }else{
    db.searchSchool((data => {
      res.send(JSON.stringify(data));
    }), content)
 }
})
// 查询专业
router.post('/searchPro', (req, res) => {
  console.log(req.url);
  let content = req.body.content;
 if(content == []) {
   res.send([])
 }else{
    db.searchPro((data => {
      res.send(JSON.stringify(data));
    }), content)
 }
})
//home/swiper
router.get('/home/swipers', (req, res) => {
  console.log(req.url);
  db.homeSwiper((data) => {
    res.send(data);
  })
})
//recommomnd_home
router.get('/home/school_recommond_img', (req, res) => {
  console.log(req.url);
  db.homeRecommond((data) => {
    res.send(data);
  })
})
//home/recommomnd_home_pro
router.get('/home/schedule_img', (req, res) => {
  console.log(req.url);
  db.homeProrecommond((data) => {
    res.send(data);
  })
})
//home/news1
router.get('/home/news_sch', (req, res) => {
  console.log(req.url);
  db.homenewsSch((data) => {
    res.send(data);
  })
})
//home/news2
router.get('/home/news_exam', (req, res) => {
  console.log(req.url);
  db.homenewsExam((data) => {
    res.send(data);
  })
})

//学校的基本信息
router.get('/sch', (req, res) => {
  console.log(req.url);
  console.log(req.query.name);
  db.searchSchoolInfo((data) => {
    res.send(data);
  },req.query.name)
})
//专业基本信息
router.get('/pro', (req, res) => {
  console.log(req.url);
  console.log(req.query.name);
  db.professionitemsTest(data => {
    res.send(data);
  }, req.query.name)
})

module.exports = router;